import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:xm_app/common/ui/AppTheme.dart';
import 'package:xm_app/common/ui/ui_adapter.dart';
import 'MainController.dart';

class MainPage extends GetView<MainController> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: PageView.builder(
        physics: NeverScrollableScrollPhysics(), //禁止页面左右滑动切换
        controller: controller.pageController,
        onPageChanged: (index) {
          //切换页面时的回调
          controller.onTap(index);
        },
        itemCount: controller.tabPage.length,
        itemBuilder: (context, index) => controller.tabPage[index],
      ),
      bottomNavigationBar: Obx(() => BottomNavigationBar(
            type: BottomNavigationBarType.fixed,
            items: controller.tabBar,
            currentIndex: controller.selectedIndex.value,
            selectedItemColor: AppTheme.pinkColor,
            unselectedItemColor: AppTheme.defColor,
            onTap: (int index) {
              controller.onTap(index);
              controller.pageController.jumpToPage(index);
            },
          )),
    );
  }
}
